package com.wy.controller;

import com.wy.dao.PanyMent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author 33117
 * @version 1.0
 * @data 2025/2/28 23:46
 */
@RestController
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    /*
     * 订单方法
     */
    @RequestMapping("order/{id}")
    public ResponseEntity<PanyMent> order(@PathVariable("id") Integer id){
        // 调用支付方法
        String url = "http://localhost:9001/payment/"+ id;
        PanyMent panyMent = restTemplate.getForObject(url, PanyMent.class);
        return ResponseEntity.ok(panyMent);
    }

    @RequestMapping("order2/{id}")
    public ResponseEntity<PanyMent> order2(@PathVariable("id") Integer id){
        // 调用支付方法
        String url = "http://payment-service/payment/"+ id;
        PanyMent panyMent = restTemplate.getForObject(url, PanyMent.class);
        return ResponseEntity.ok(panyMent);
    }
}
